package com.chaoyi.vo;


import com.alibaba.fastjson.JSONObject;

public class UserAction {
	private int id;
	private String deviceNo;
	private String osVersion;
	private String imei;
	private String imsi;
	private String androidId;
	private String screenh;
	private String screenw;
	private String deviceManufacturer;
	private String deviceType;
	private String netConnectionType;
	private String ip;  
	private String channelId;
	private String appVersionName;
	private String appVersionCode;	
	private int action;
	private String createTime;
	private String createDate;
	private int videoId;
	
	
	public int getVideoId() {
		return videoId;
	}
	public void setVideoId(int videoId) {
		this.videoId = videoId;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getDeviceNo() {
		return deviceNo;
	}
	public void setDeviceNo(String deviceNo) {
		this.deviceNo = deviceNo;
	}
	public String getOsVersion() {
		return osVersion;
	}
	public void setOsVersion(String osVersion) {
		this.osVersion = osVersion;
	}
	public String getImei() {
		return imei;
	}
	public void setImei(String imei) {
		this.imei = imei;
	}
	public String getImsi() {
		return imsi;
	}
	public void setImsi(String imsi) {
		this.imsi = imsi;
	}
	public String getAndroidId() {
		return androidId;
	}
	public void setAndroidId(String androidId) {
		this.androidId = androidId;
	}
	public String getScreenh() {
		return screenh;
	}
	public void setScreenh(String screenh) {
		this.screenh = screenh;
	}
	public String getScreenw() {
		return screenw;
	}
	public void setScreenw(String screenw) {
		this.screenw = screenw;
	}
	public String getDeviceManufacturer() {
		return deviceManufacturer;
	}
	public void setDeviceManufacturer(String deviceManufacturer) {
		this.deviceManufacturer = deviceManufacturer;
	}
	public String getDeviceType() {
		return deviceType;
	}
	public void setDeviceType(String deviceType) {
		this.deviceType = deviceType;
	}
	public String getNetConnectionType() {
		return netConnectionType;
	}
	public void setNetConnectionType(String netConnectionType) {
		this.netConnectionType = netConnectionType;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getChannelId() {
		return channelId;
	}
	public void setChannelId(String channelId) {
		this.channelId = channelId;
	}
	public String getAppVersionName() {
		return appVersionName;
	}
	public void setAppVersionName(String appVersionName) {
		this.appVersionName = appVersionName;
	}
	public String getAppVersionCode() {
		return appVersionCode;
	}
	public void setAppVersionCode(String appVersionCode) {
		this.appVersionCode = appVersionCode;
	}
	public int getAction() {
		return action;
	}
	public void setAction(int action) {
		this.action = action;
	}
	public String getCreateDate() {
		return createDate;
	}
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	
	public static UserAction fromJSON(JSONObject json){
		UserAction userAction = new UserAction();
		userAction.setId(json.getIntValue("id"));
		userAction.setDeviceNo(json.getString("deviceNo"));
		userAction.setOsVersion(json.getString("osVersion"));
		userAction.setImei(json.getString("imei"));
		userAction.setImsi(json.getString("imsi"));
		userAction.setAndroidId(json.getString("androidId"));
		userAction.setScreenh(json.getString("screenh"));
		userAction.setScreenw(json.getString("screenw"));
		userAction.setDeviceManufacturer(json.getString("deviceManufacturer"));
		userAction.setDeviceType(json.getString("deviceType"));
		userAction.setNetConnectionType(json.getString("netConnectionType"));
		userAction.setIp(json.getString("ip"));
		userAction.setChannelId(json.getString("channelId"));
		userAction.setAppVersionName(json.getString("appVersionName"));
		userAction.setAppVersionCode(json.getString("appVersionCode"));
		userAction.setAction(json.getIntValue("action"));
		userAction.setCreateTime(json.getString("createTime"));
		userAction.setCreateDate(json.getString("createDate"));
		int videoId = 0;
		try{
			videoId = Integer.parseInt(json.getString("videoId"));
			if(videoId < 0){
				videoId = 0;
			}
		}catch(Exception e){
			
		}
		userAction.setVideoId(videoId);
		return userAction;
	}
	
	public JSONObject toJSON(){
		JSONObject json = new JSONObject();
		json.put("id", id);
		json.put("deviceNo", deviceNo);
		json.put("osVersion", osVersion);
		json.put("imei", imei);
		json.put("imsi", imsi);
		json.put("androidId", androidId);
		json.put("screenh", screenh);
		json.put("screenw", screenw);
		json.put("deviceManufacturer",deviceManufacturer);
		json.put("deviceType", deviceType);
		json.put("netConnectionType",netConnectionType);
		json.put("ip", ip);
		json.put("channelId", channelId);
		json.put("appVersionName", appVersionName);
		json.put("appVersionCode", appVersionCode);
		json.put("action", action);
		json.put("createTime", createTime);
		json.put("createDate", createDate);
		json.put("videoId", videoId);
		return json;
	}
	
}
